package com.woniu.utils;

import org.springframework.util.DigestUtils;

public class UserPassWordEncodeHelper {
    /**
     * @param password
     * @param salt
     * @return
     */
    public static String encodePassword(String password, String salt) {
        return DigestUtils.md5DigestAsHex((salt.charAt(0) + salt.charAt(2) + password + salt.charAt(5) + salt.charAt(4)).getBytes());
    }

    public static boolean match(String password, String salt, String dbPassword) {
        password = encodePassword(password, salt);
        return password.equals(dbPassword);
    }

}
